package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.DeleteFlightView;
import group2assignone.view.manager.ManagerView;

/**
 * Use Case: Create Flight                                              <br>
 * Pre-Condition: Manager selects 'Delete' from the delete flight view  <br>                                        <br>
 * Post-Condition: UI is updated                                        <br>
 * 1. System deletes the flight.                                        <br>
 * 2. System closes the delete flight view.                             <br>
 * 3. System updates UI to the manager main menu.                       <br>
 *
 * @author group2
 */
public class UCDeleteFlight implements UCController {

    private DeleteFlightView deleteView = new DeleteFlightView();

    /**
     * sets view and flight
     * @param dView
     * @param flight
     */
    public UCDeleteFlight(DeleteFlightView dView, Flight flight) {
        deleteView = dView;
    }

     /**
     *Use Case Controller - allows the manager to Delete a Flight
     */
    @Override
    public void run() {
        //1. System deletes the flight.
        MyDAO coms = UCStartup.getInstance().getDAO();
        coms.sQLDeleteFlight(deleteView.getFlightNum());
        //2. System closes the delete flight view.
        deleteView.dispose();
        //3. System updates UI to the manager main menu.
        ManagerView mv = ManagerView.getInstance();
        mv.go();
    }
}
